﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace MapEntities
{
    [Serializable]
    public class SymbolItemBindingRule : LayerItemBindingRule
    {
        public string LongitudeField { get; set; }
        public string LatitudeField { get; set; }

        private SymbolItemVisualization visualization = null;
        private SymbolItemBehavior behavior = null;


        public virtual SymbolItemBehavior Behaviour
        {
            get
            {
                if (behavior == null)
                    behavior = new SymbolItemBehavior();                
                return behavior;
            }

            set
            {
                behavior = value;
            }
        }

        public virtual SymbolItemVisualization Visualization
        {
            get
            {
                if (visualization == null)
                    visualization = new SymbolItemVisualization();
                return visualization;
            }

            set
            {
                visualization = value;
            }
        }
    }

    [Serializable]
    public class SymbolItemBindingRuleList : List<SymbolItemBindingRule>
    {
        public SymbolItemBindingRule this[Guid id]
        {
            get
            {
                foreach (var item in this)
                    if (item.ID == id)
                        return item;
                return null;
            }

            set
            {
                for (int i = 0; i < this.Count; i++)
                    if (this[i].ID == id)
                        this[i] = value;
            }
        }
    }
}
